﻿Imports System.Data.SqlClient

Public Class clsAbonosInfonavit
    Private mintcidAbono As Integer
    Private mintcIdEmpleado As Integer
    Private mintcidNomina As Integer
    Private mintcBimestre As Integer
    Private mintcPeriodo As Integer
    Private mdblcMonto As Double
    Private mintcAnio As Integer
    Public Property cIdAbono() As Integer
        Get
            Return mintcidAbono
        End Get
        Set(ByVal value As Integer)
            mintcidAbono = value
        End Set
    End Property
    Public Property cIdEmpleado() As Integer
        Get
            Return mintcIdEmpleado
        End Get
        Set(ByVal value As Integer)
            mintcIdEmpleado = value
        End Set
    End Property
    Public Property cidNomina() As Integer
        Get
            Return mintcidNomina
        End Get
        Set(ByVal value As Integer)
            mintcidNomina = value
        End Set
    End Property
    Public Property cBimestre() As Integer
        Get
            Return mintcBimestre
        End Get
        Set(ByVal value As Integer)
            mintcBimestre = value
        End Set
    End Property
    Public Property cPeriodo() As Integer
        Get
            Return mintcPeriodo
        End Get
        Set(ByVal value As Integer)
            mintcPeriodo = value
        End Set
    End Property
    Public Property cMonto() As Double
        Get
            Return mdblcMonto
        End Get
        Set(ByVal value As Double)
            mdblcMonto = value
        End Set
    End Property
    Public Property cAnio() As Integer
        Get
            Return mintcAnio
        End Get
        Set(ByVal value As Integer)
            mintcAnio = value
        End Set
    End Property

    Public Sub New()
        mintcidAbono = 0
        mintcIdEmpleado = 0
        mintcidNomina = 0
        mintcBimestre = 0
        mintcPeriodo = 0
        mdblcMonto = 0
        mintcAnio = 0
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From AbonosInfonavit Where IdAbono = " & cIdAbono)
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into AbonosInfonavit (" & _
                            "IdAbono," & _
                            "IdEmpleado," & _
                            "IdNomina," & _
                            "Bimestre," & _
                            "Periodo," & _
                            "Monto," & _
                            "Anio) " & _
                            "VALUES (" & _
                            "@IdAbono," & _
                            "@IdEmpleado," & _
                            "@IdNomina," & _
                            "@Bimestre," & _
                            "@Periodo," & _
                            "@Monto," & _
                            "@Anio) "


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdAbono", mintcidAbono)
        Command.Parameters.AddWithValue("IdEmpleado", mintcIdEmpleado)
        Command.Parameters.AddWithValue("IdNomina", mintcidNomina)
        Command.Parameters.AddWithValue("Bimestre", mintcBimestre)
        Command.Parameters.AddWithValue("Periodo", mintcPeriodo)
        Command.Parameters.AddWithValue("Monto", mdblcMonto)
        Command.Parameters.AddWithValue("Anio", mintcAnio)
        

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
